<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <title>localStroage</title>
</head>
<body>
    <!-- 本地存储：存储内容需要手动清除  浏览器查看：Application  应用：历史记录-->
    <br>
    <button onclick="saveData()">点我保存数据</button>
    <button onclick="readData()">点我读取数据</button>
    <button onclick="deleteData()">点我删除数据</button>
    <button onclick="clearData()">点我清除所有数据</button>

    <script type="text/javascript">
        let p = {name: "brx", age: "22"}

        function saveData(){
            localStorage.setItem("msg", "hello")
            localStorage.setItem("message", "123")
            localStorage.setItem("p1", JSON.stringify(p))
        }

        function readData(){
            console.log(localStorage.getItem("msg"))
            console.log(localStorage.getItem("message"))
            res = localStorage.getItem("p1")
            console.log(res)
        }

        function deleteData(){
            localStorage.removeItem("message")
        }

        function clearData(){
            localStorage.clear()
        }
    </script>
</body>
</html>